package com.wwt.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wwt.blog.pojo.Tag;
import com.wwt.blog.vo.TagVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TagMapper extends BaseMapper<Tag> {
    @Select("select id,avatar,tag_name as tagName from ms_tag where id in" +
            "(select tag_id from ms_article_tag " +
            "where article_id=#{articleId})")
    List<Tag> findTagsByArticleId(Long articleId);

    @Select("select tag_id from ms_article_tag group by tag_id order by count(*) desc limit #{limit}")
    List<Long> findTagsId(int limit);
    //根据查找出来的最热标签来查找这些标签名
    List<TagVo> findTagByIds(List<Long> tags);
}
